package main

import (
    "io/ioutil"
    "strings"
)

type Config struct {
    Listen string
}

func NewConfig() *Config {
    v := &Config{}

    v.Listen = ":3456"

    return v
}

var g_config *Config

func loadConfig() *Config {
    c := NewConfig()

    buf, err := ioutil.ReadFile("/etc/update_service/default.ini")
    if err != nil {
        mainlog.Println("read config file failed.", err)
        return c
    }

    lines := strings.Split(string(buf), "\n")
    for _,line := range lines {
        line = strings.TrimSpace(line)
        if line == "" || line[0] == ';' {
            continue
        }

	    if strings.Index(line, "listen=") == 0 {
            c.Listen = strings.TrimSpace(line[7:])
		}
    }

    return c
}